package com.chenjiahao.kaiyanwan.ui.home

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations
import androidx.lifecycle.ViewModel
import com.chenjiahao.kaiyanwan.logic.dao.Repository
import com.hazz.kotlinmvp.mvp.model.bean.HomeBean

class HomeViewModel : ViewModel() {
    private val numLiveData = MutableLiveData<Int>()

    private val moreHomeData = MutableLiveData<String>()

    val itemList = ArrayList<HomeBean.Issue.Item>()

    val homeLiveData = Transformations.switchMap(numLiveData) {
        Repository.getFirstHomeData(it)
    }
    val homeMoreLiveData = Transformations.switchMap(moreHomeData) {
        Repository.getMoreHomeData(it)
    }

    fun getMoreData(nextPageUrl: String) {
        moreHomeData.value =nextPageUrl
    }


    fun getHomeData(num: Int) {
        numLiveData.value = num
    }
}